package com.lqian.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.lqian.pojo.Depart;

public interface DepartMapper {

	/**
	 *  select all depart
	 * @return
	 */
	@Select("select * from depart")
	List<Depart> getAllDepart();

	/**
	 * add depart
	 */
	@Insert("INSERT INTO depart VALUES(null,#{dname},#{duty},NOW(),1)")
	void addDepart(Depart depart);

	//通过did查找部门信息   返回值：depart  参数：did
	@Select("select * from depart where did=#{did}")
	Depart findDepartByDid(@Param("did") Integer did);

	/**
	 * update depart
	 */
	@Update("update depart set dname = #{dname},duty = #{duty} where did = #{did}")
	Integer updateDepart(Depart depart);

	//删除  返回：整数  参数  ： did
	@Update("update depart set dstatus=1 where did=#{did}")
	Integer deleteDepart(@Param("did")Integer did);

	//恢复  返回：整数  参数  ： did
	@Update("update depart set dstatus=0 where did=#{did}")
	Integer resDepart(@Param("did")Integer did);

}
